package com.deke.security.handler;

import com.deke.security.exception.PermissionException;
import com.deke.vo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author ：Username 刘亦辰（59372312@qq.com）
 * @date ：Created in 2022/12/2 19:39
 * @description：全局异常处理
 * @modified By：
 * @version:
 **/
//标记为全局异常处理类
@RestControllerAdvice
public class MyGlobalHandler {
    //如果你抛出PermissonException,则有该方法处理这个异常
    @ExceptionHandler(value = PermissionException.class)
    public Result<String> permissionException(Exception e){
        return new Result<>(4003,e.getMessage());
    }
}